package com.dyna.mapper;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.dyna.foundation.domain.entity.SysUserRole;
import org.apache.ibatis.annotations.Mapper;

import java.util.Collection;
import java.util.List;

/**
* @author zhoucaiwang
*/

@Mapper
public interface SysUserRoleMapper extends BaseMapperX<SysUserRole> {

    default List<SysUserRole> selectListByUserId(Long userId) {
        return selectList(SysUserRole::getUserId, userId);
    }

    default void deleteListByUserIdAndRoleIdIds(Long userId, Collection<Long> roleIds) {
        delete(new LambdaQueryWrapper<SysUserRole>()
                .eq(SysUserRole::getUserId, userId)
                .in(SysUserRole::getRoleId, roleIds));
    }

    default void deleteListByUserId(Long userId) {
        delete(new LambdaQueryWrapper<SysUserRole>().eq(SysUserRole::getUserId, userId));
    }

    default void deleteListByRoleId(Long roleId) {
        delete(new LambdaQueryWrapper<SysUserRole>().eq(SysUserRole::getRoleId, roleId));
    }

    default List<SysUserRole> selectListByRoleIds(Collection<Long> roleIds) {
        return selectList(SysUserRole::getRoleId, roleIds);
    }

}




